package com.example.xyxwebbackend001.model.DTO;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.time.LocalDateTime;
import java.util.List;

@Data
public class TPostsDTO {
    private Integer postId;
    private Integer userId;
    private String  avatarPath;
    private String username;
    private String title;
    private String content;
    private String imagePath;
    private LocalDateTime createdAt;
    private String tags;
    private Integer likesCount;
    private Integer favoritesCount;
    private Boolean likedByCurrentUser;
    private Boolean favoritedByCurrentUser;
    private List<CommentDTO> comments;

    @Data
    @NoArgsConstructor
    @AllArgsConstructor
    @JsonIgnoreProperties(ignoreUnknown = true)
    public static class CommentDTO {
        @JsonProperty("t_comment_id")
        private Integer commentId;

        private String username;
        private String content;

        @JsonProperty("t_created_at")
        @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss")
        private LocalDateTime createdAt;
    }
}
